#!/usr/bin/env python
"""
__version__ = "$Revision: 1.5 $"
__date__ = "$Date: 2004/04/30 16:26:12 $"
"""

from PythonCard import model, dialog
import os

class MyBackground(model.Background):
    def on_initialize(self, event):
        self.components.restore.enabled=False
        self.components.shsh.enabled=False
        self.components.pwn.enabled=False
    def on_browse_mouseClick(self, event):
        wildcard = "iPod/iPhone/iPad Software files (*.ipsw)|*.ipsw"
        x=dialog.openFileDialog(wildcard=wildcard)
        x.paths=x.paths.pop()
        self.components.ipswinput.text=str(x.paths)
        self.components.restore.enabled=True
        self.components.shsh.enabled=True
        self.components.pwn.enabled=True
    def on_restore_mouseClick(self,event):
        if self.components.cydia.checked==True:
            cydia="--cydia"
        else:
            cydia=""
        if self.components.baseband.checked==True:
            bb="-x"
        else:
            bb=""
        if self.components.custom.checked==True:
            custom="-c"
        else:
            custom=""
        if self.components.full.checked==True:
            full="-e"
        else:
            full=""
        os.system=("idevicerestore %s %s %s %s %s" % (cydia, bb, custom, full, self.components.ipswinput.text))
    def on_shsh_mouseClick(self,event):
        os.system("idevicerestore --shsh %s" % self.components.ipswinput.text)
    def on_pwn_mouseClick(self,event):
        os.system("idevicerestore --pwn %s" % self.components.ipswinput.text)
        
if __name__ == '__main__':
    app = model.Application(MyBackground)
    app.MainLoop()
